package com.lp.biz.message.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lp.biz.message.mapper.BizMessageUpdateMapper;
import com.lp.biz.message.model.entity.BizMessageUpdate;
import com.lp.biz.message.service.BizMessageUpdateService;
import com.lp.biz.content.model.entity.BizCoreContent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @program: backend
 * @description: BizMessageUpdate 服务实现类
 * @author Ke.Song
 * @since 2024-04-27 14:51:35
 */
@Slf4j
@Service
public class BizMessageUpdateServiceImpl extends ServiceImpl<BizMessageUpdateMapper, BizMessageUpdate> implements BizMessageUpdateService {

    @Autowired
    private BizMessageUpdateMapper messageUpdateMapper;

    @Override
    @Transactional(rollbackFor = RuntimeException.class)
    public void addUpdateMessage(BizCoreContent content) {
        BizMessageUpdate bizMessageUpdate = new BizMessageUpdate();
        bizMessageUpdate.setBizCoreContentId(content.getId());
        bizMessageUpdate.setBizCoreContentCode(content.getBizCategoryCode());
        bizMessageUpdate.setCreateAt(content.getCreateAt());
        messageUpdateMapper.addNewMessage(bizMessageUpdate);
        log.info("分发上新消息成功，上新内容: <<{}>>, 类型：{}", content.getTitle(), content.getBizCategoryCode());
    }
}
